<!-- 无数据组件 -->
<template>
	<view class="nodata">
		<view class="content hasbtn" v-if="type=='hasbtn'">
		  <!-- #ifdef H5 -->
		   <img class="icon" :src="icon" :style="{'margin-bottom':iconBottom,'width':iconWidth,'height':iconHeight}"></img>
		  <!-- #endif -->
		  <!-- #ifdef MP -->
		   <image class="icon" :src="icon" :style="{'margin-bottom':iconBottom,'width':iconWidth,'height':iconHeight}"></image>
		  <!-- #endif -->
		   <rich-text class="name" :nodes="text"></rich-text>
		   <button class="btn btn-yellow nodata-btn" @click="btnClick">{{btnText}}</button>	
		</view>
		
		<view class="content nobtn" v-if="type=='nobtn'">
		  <!-- #ifdef H5 -->
		   <img class="icon" :src="icon" :style="{'margin-bottom':iconBottom,'width':iconWidth,'height':iconHeight}"></img>
		  <!-- #endif -->
		  <!-- #ifdef MP -->
		   <image class="icon" :src="icon" :style="{'margin-bottom':iconBottom,'width':iconWidth,'height':iconHeight}"></image>
		  <!-- #endif -->
		   <rich-text class="name" :nodes="text"></rich-text>
		  
		</view>
	</view>
</template>

<script>
	
	export default {
		props:{
			type: {
				//样子类型
				type: String,
				default: 'hasbtn' //'hasbtn' 'nobtn'
			},
			icon: {
				//图标地址 或 文字图标类名
				type: String,
				default: '../../static/img_nodata.png'
			},
			iconW:{
				// 图标宽度大小
				type: Number|String,
				default: 100
			}
			,
			iconH:{
				// 图标高度大小
				type: Number|String,
				default: 100
			}
			,
			iconBottom:{
				// 图标 bottom 下边外边距
				type:String,
				default:'40rpx'
			},
			text: {
				//文本
				type: String,
				default: '无数据'
			},
			btnText: {
				//图标地址 或 文字图标类名
				ype: String,
				default: '刷新'
			},
		},
		data() {
			return {
				
			};
		},
		computed:{
			iconWidth(){
				if(typeof this.iconW=="string")
				return this.iconW
				else
				return this.iconW+"rpx"
			},
			iconHeight(){
				if(typeof this.iconH=="string")
				return this.iconH
				else
				return this.iconH+"rpx"
			}
		},
		methods:{
			btnClick(event){
				// 按钮被点击
				console.log("点击")
				this.$emit("btnClick",event)
			}
		}
	}
</script>

<style lang="scss">
	.nodata{
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		width: 100%;
		height: 100%;
		position: relative;
		.content{
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			width: 100%;
			position: relative;
		}
		.content.hasbtn{
			.icon{
				width: 80%;
				
			}
			.name{
				font-size: 36rpx;
				color: #46494D;
				text-align: center;
			}
			.nodata-btn{
				margin-top: 30rpx;
				font-size: 34rpx;
				width: 50%;
				text-align: center;
				padding: 20rpx 0rpx;
			}
		}
		
		.content.nobtn{
			.icon{
				width: 80%;
				
			}
			.name{
				font-size: 36rpx;
				text-align: center;
				color: #46494D;
				// position: absolute;
				bottom: 148rpx;
			}
		
		}
		
	}
</style>
